Events

Following is a listing of events fired by the DjVu Browser Plug-in along with their descriptions.

Name Description
PageChange (ByVal long newpage)

Fired after the page changes, after the newly current page is decoded. Methods and properties that depend on the decode status of the document should be called from this event.

Example (JScript):

    <SCRIPT FOR=myDjVu EVENT="PageChange(newpage)"

    LANGUAGE="JScript">

       alert("Page changed to " + newpage)

    </SCRIPT>                        

ZoomChange (ByVal BSTR newzoom)

Fired after the zoom changes.

Example (JScript):

    <SCRIPT FOR=myDjVu EVENT="ZoomChange(newzoom)"

    LANGUAGE="JScript">

         alert("Zoom Changed to " + newzoom);

    </SCRIPT>

DisplayModeChange (ByVal BSTR newlayer)

Fired whenever a new layer is selected for view.

Example (JScript):

    <SCRIPT FOR=myDjVu EVENT="DisplayModeChange(newlayer)"

    LANGUAGE="JScript">

       alert("Layer Changed to " + newlayer);

    </SCRIPT>

BackForwardChange (ByVal BSTR backforward)

Fired whenever the view changes.

backforward is of the format “m,n”, where m is the number of steps you can retrace backward in navigational history and n is the number of steps you can retrace forward.

Example (JScript):

    <SCRIPT FOR=myDjVu EVENT="BackForwardChange(backforward)"

    LANGUAGE="JScript">

       alert("Backforward history is now " + backforward);

    </SCRIPT>

ScrollEvent (ByVal BSTR hv)

Fired whenever user pans or moves the scrollbar.

hv is of the format “x,y” where x and y are both numbers between 0 and 1 representing the scrolling position.

Example (JScript):

    <SCRIPT FOR=myDjVu EVENT="ScrollEvent(hv)"

    LANGUAGE="JScript">

       alert("Scroll changed to " + hv);

    </SCRIPT>

HyperlinkClick (Bool pDolink, BSTR pUrl, BSTR pTarget, BSTR pComment)

Fired when a hyperlink is clicked to enable blocking, redirecting or granting link access. Note: Only applicable when a DjVu document contains hyperlinks:

Example (Visual Basic):

    Private Sub DjVuCtl1_HyperlinkClick(pDolink As Boolean, pUrl As String,

    pTarget As String, pComment As String)

       If (pUrl = "http://www.lizardtech.com/") then

          pDolink = 1 pUrl = "http://www.extensis.com"

          pTarget = "new"

          pComment = "If original URL is http://www.lizardtech.com/, redirect to

          http://www.extensis.com in a new window"

       ElseIf (pUrl = "http://www.extensis.com") Then

          pDolink = 0

          pComment = "If original URL is http://www.extensis.com, block link"

       Else

          pDolink = 1

          pUrl = "http://www.msn.com"

          pComment = "If any other URL, redirect to http://www.celartem.com"

       End If

    End Sub

PlugInError (BbVal BSTR message)

Fired when an error occurs.

Example:

    <SCRIPT FOR=myDjVu EVENT="PluginError(message)"

    LANGUAGE="JScript">

       alert("Error: " + message);

    </SCRIPT>

LayoutChange (ByVal BSTR newlayout)

Fired when the layout is changed.

Example (Jscript):

    <SCRIPT FOR=myDjVu EVENT="LayoutChange(newlayout)"

    LANGUAGE="JScript">

       alert("Layout changed to " + newlayout);

    </SCRIPT>

RequestPassword (ByVal BSTR ReqUrl, ByVal int nRegId, ByVal int nReTry)

Fired when a user attempts to open a secure DjVu file.

Example (JScript):

    <SCRIPT FOR=myDjVu EVENT="RequestPassword (ReqUrl,nRegId, nReTry)"

    LANGUAGE="JScript">

       alert(ReqUrl.toString() + "is a secured DjVu file,

       please enter UserID and Password. This is request

       number "+ nReTry.toString() + ".");

    </SCRIPT>

Note:nReTry is a zero-based request number. The first try is nReTry=0. The second try (the first actual retry) is nReTry=1.

DocumentExpired (ByVal BSTR Url, Bool bOpenIt)

Fired when all three of the following criteria are met:

  • user attempts to open a secure DjVu file that has an expiry date set
  • the expiry date has passed
  • the document requires that an event be fired

Example (Visual Basic):

If an expired document was secured with the following parameters, viewing will fail except for documents whose expiry date is 03/05/2006.

    Private Sub DjVuCtl1_DocumentExpired(ByVal Url As

    String, bOpenIt As Boolean)

       If (DjVuCtl1.ExpiryDate = "03/05/2006") Then

          bOpenIt = True MsgBox "Access granted: File expired on " +

          DjVuCtl1.ExpiryDate Else

          bOpenIt = False MsgBox "Access denied: File expired on " +

          DjVuCtl1.ExpiryDate

       End If

    End Sub